<!--
 * @Author: Wangtao
 * @Date: 2022-06-18 22:11:45
 * @LastEditors: Wangtao
 * @LastEditTime: 2022-06-23 10:45:41
-->
<template>
  <div class="interfaceConfig">
    <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane :label="item.name"
                     :name="item.value"
                     :key="item.value"
                     v-for="item in menu"></el-tab-pane>
      </el-tabs>
    <div  class="wapper">
        <keep-alive>
          <router-view></router-view>
        </keep-alive>
    </div>
  </div>
</template>
<script>
  import { isHasMenu } from '@/utils/m7Utils'
  export default {
    name: 'interfaceConfig',
    data () {
      return {
        activeName: '',
        menu: [
          {name: this.$t('configLazyLoad.dicConfig.dicConfigList'), value: 'dicConfigList', id: 'dicConfigList'},
          {name: this.$t('configLazyLoad.dicConfig.ImportTaskList'), value: 'ImportTaskList', id: 'ImportTaskList'},
        ]
      }
    },
    computed: {
    },
    methods: {
      isCallEvent () {
        // this.menu = this.menu.filter(item => {
        //   return !item.id || (item.id && isHasMenu(item.id, this.$store.state.session.user))
        // })
        this.activeName = this.menu[0].value
        this.$router.push({path: '/index/config/dicConfig/' + this.activeName})
      },
      handleClick (tab) {
        this.$router.push({path: '/index/config/dicConfig/' + tab.name})
      }
    },
    beforeMount () {
      this.isCallEvent()
      if (!isHasMenu('dic_import', this.$store.state.session.user) && !this.$store.state.session.user.isAdmin) {
        this.menu = [
          {name: this.$t('configLazyLoad.dicConfig.dicConfigList'), value: 'dicConfigList', id: 'dicConfigList'}
        ]
      }
    },
    beforeRouteLeave (to, from, next) {
      this.currentRoute = from.fullPath
      next()
    },
    beforeRouteEnter (to, from, next) {
      next(vm => {
        if (to.query.active) {
        } else if (vm.currentRoute) {
          vm.$router.push({path: vm.currentRoute})
        }
      })
    }
  }
</script>
<style lang="stylus" scoped>
  @import "../../../../assets/common.styl"
  .interfaceConfig
    height calc(100vh - 96px)
</style>
